package com.engine.downcustomfile.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.downcustomfile.service.impl.DownCustomFileServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import java.util.HashMap;
import java.util.Map;


/**
 * @author Administrator
 */
public class DownCustomFileAction{
    private static DownCustomFileServiceImpl getService(User user) {
        return ServiceUtil.getService(DownCustomFileServiceImpl.class, user);
    }

    @POST
    @Path("/doDownFile")
    public String doDownFile(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Map<String, Object> apidatas = new HashMap<>();
        User user = HrmUserVarify.getUser(request, response);
        apidatas = getService((user)).doDownFile(ParamUtil.request2Map(request), user);
        apidatas.put("status", "1");

        return JSONObject.toJSONString(apidatas);
    }
}
